<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title></title>

	<link rel="stylesheet" href="./Public/Admin/Bootstrap/Css/bootstrap.min.css" />
	<script type="text/javascript" src='./Public/Admin/js/jquery-1.8.2.min.js'></script>
	<!-- <script type="text/javascript" src='./Public/Admin/uploadify/jquery.uploadify.min.js'></script> -->
	<!-- 处理上传类的js、css -->
	<!-- <script type="text/javascript" src="./Public/Admin/uploadify/jquery-1.8.2.min.js"></script> -->
	<script type="text/javascript" src="./Public/Admin/uploadify/jquery.uploadify.min.js"></script>
	<link href="./Public/Admin/uploadify/uploadify.css" type="text/css" rel="stylesheet"></link>
	<!-- 引入编辑器 -->
	<script type="text/javascript" charset="utf-8" src="./Public/ueditor1_4_3/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="./Public/ueditor1_4_3/ueditor.all.min.js"> </script>
	<script type="text/javascript" charset="utf-8" src="./Public/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
	<!-- 处理商品属性及规格的js -->
	<script type="text/javascript" src="./Public/Admin/js/goods.js"></script>
	
	<style type="text/css">
		/*去掉uploadify上传按钮的边框*/
	    .uploadify-button {
	        background-color: transparent;
	        border: none;
	        padding: 0;
	    }
	    .uploadify:hover .uploadify-button {
	        background-color: transparent;
    	}
    	li{
    		list-style-type: none;
    	}
    	.hide{
    		display: none;
    	}
    	body{
    		margin-bottom: 100px;
    	}
	</style> 
</head>
<body>
	<div class="container-fluid">
	<div class="row-fluid">
	<div class="span12">
	<form action="" method='post' enctype="multipart/form-data">
		<fieldset>
			<legend>添加商品</legend>
			<table class='table table-bordered table-hover'>
				<thead>
					<tr>
						<th colspan="2" class="btn btn-primary">基本信息</th>
					</tr>
				</thead>
				<tbody>
					<tr class="info">
						<td>所属分类</td>
						<td>
							<select name="cid">
								<option value="0" tid='0'>-请选择-</option>
								<?php foreach ($cateData as $v){?>
								<option value="<?php echo $v['cid']?>" tid="<?php echo $v['type_tid']?>"><?php echo $v['_name']?></option>
								<?php }?>
							</select>
						</td>
					</tr>
					
					<tr class="info">
						<td>所属品牌</td>
						<td>
							<select name="bid">
								<option value="0">-请选择-</option>
								<?php foreach ($brandData as $v){?>
								<option value="<?php echo $v['bid']?>"><?php echo $v['bname']?></option>
								<?php }?>
							</select>
						</td>
					</tr>
					<tr class="info">
						<td>商品名称</td>
						<td>
							<input type="text" name='gname'/>
						</td>
					</tr>
					<tr class="info">
						<td>商品货号</td>
						<td>
							<input type="text" name='gnumber'/>
						</td>
					</tr>
					<tr class="info">
						<td>单位</td>
						<td>
							<input type="text" name='unit' value='件'/>
						</td>
					</tr>
					<tr class="info">
						<td>市价场</td>
						<td>
							<input type="text" name='marketprice'/>
						</td>
					</tr>
					<tr class="info">
						<td>商城价</td>
						<td>
							<input type="text" name='shopprice'/>
						</td>
					</tr>
					<tr class="info">
						<td>点击次数</td>
						<td>
							<input type="text" name='click'/>
						</td>
					</tr>
				</tbody>
			</table>

			<p class="btn btn-primary">商品属性</p>
			<table class="table table-bordered table-hover" id='attr' class="info">
				<!-- 这儿是接收异步添加的attr -->
			</table>
			<p class="btn btn-primary">商品规格</p>
			<table class="table table-bordered table-hover" id='spec'>
				<!-- 这儿是接收异步添加的spec 且还有相同规格名的添加删除功能-->
			</table>
			<table class='table table-bordered'>
				<tr>
					<th colspan="3" class="btn btn-primary">列表图</th>
				</tr>
				<tr class="info">
					<td>上传图片</td>
					<td>
						<input id="file1" type="file" multiple="true" name="photos"/>
	            		 <span>类型: *.jpg,*.png 大小: 235*314 数量: 10</span>
			             <script type="text/javascript">
						    $(function() {
						        $('#file1').uploadify({
						            'formData'     : {//POST数据
						                '<?php echo session_name();?>' : '<?php echo session_id();?>',
						            },
						            'fileTypeDesc' : '上传文件',//上传描述
						            'fileTypeExts' : '*.jpg;*.png;*.jpeg;*.gif',   //允许上传的类型
						            'swf'      : './Public/Admin/uploadify/uploadify.swf', //必须得存在的swf
						            'uploader' : "<?php echo U('ajaxUpload')?>",  //异步上传逻辑处理路径
						            'buttonText':'选择文件',
						            'fileSizeLimit' : '2000KB',
						            'uploadLimit' : 1000,//上传文件数
						            'width':65,
						            'height':25,
						            'successTimeout':10,//等待服务器响应时间
						            'removeTimeout' : 0.2,//成功显示时间
						            'onUploadSuccess' : function(file, data, response) {
						                data=$.parseJSON(data);
						                // console.log(data);
						                var imageUrl = data.image?data.url:'./Upload/image/default.png';//这是上传图片的存储路径，三元表达式，如果有图片路径，那使用的是定义的图片路径，否则使用默认的图片路径和格式。
						                console.log(imageUrl);
						               var li = '<li url="'+data.path+'" style="float:right ;"><img src="'+data.path+'" style="width:150px;height:150px;float:right;"/>';
										 li += '<input type="hidden" name="pic[]" id="" value="'+data.path+'" />';
										 li += '<a href="javascript:;" class="delImg" style="color:red">X</a></li>';
						                $("#pic-list").prepend(li);
						            }
						        });
						    });
						 </script>
						 	<!-- 异步删除图片-->
						<script type="text/javascript">
							$(function(){
								$(".delImg").live("click",function(){
									var url = $(this).parents("li").attr("url");
									var _this=$(this);
									$.ajax({
										type:"post",
										url:"<?php echo U('ajaxDelImg')?>",
										data:{url:url},
										dataType:"json",
										success:function(data){
											if(data==1){
												_this.parents("li").remove();
											}
										}
									});
								})
							})
						</script>
					</td>
					<td id='pic-list'></td>
				</tr>
			</table>

			<table class='table table-bordered'>
				<tr>
					<th colspan="3" class="btn btn-primary">商品图册</th>
				</tr>
				<tr class="info">
					<td>上传图片</td>
					<td>
						<input id="file2" type="file" multiple="true" name="photos2"/>
	            		 <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
			             <script type="text/javascript">
						    $(function() {
						        $('#file2').uploadify({
						            'formData'     : {//POST数据
						                '<?php echo session_name();?>' : '<?php echo session_id();?>',
						            },
						            'fileTypeDesc' : '上传文件',//上传描述
						            'fileTypeExts' : '*.jpg;*.png;*.jpeg;*.gif',   //允许上传的类型
						            'swf'      : './Public/Admin/uploadify/uploadify.swf', //必须得存在的swf
						            'uploader' : "<?php echo U('ajaxUpload1')?>",  //异步上传逻辑处理路径
						            'buttonText':'选择文件',
						            'fileSizeLimit' : '2000KB',
						            'uploadLimit' : 1000,//上传文件数
						            'width':65,
						            'height':25,
						            'successTimeout':10,//等待服务器响应时间
						            'removeTimeout' : 0.2,//成功显示时间
						            'onUploadSuccess' : function(file, data, response) {
						                data=$.parseJSON(data);
						                // console.log(data);
						                var imageUrl = data.image?data.url:'./Upload/image/default.png';//这是上传图片的存储路径，三元表达式，如果有图片路径，那使用的是定义的图片路径，否则使用默认的图片路径和格式。
						                console.log(imageUrl);
						               var li = '<li url="'+data.path+'" style="float:right ;"><img src="'+data.path+'" style="width:150px;height:150px;float:left;"/>';
										 li += '<input type="hidden" name="big[]" id="" value="'+data.newpath+'" /><input type="hidden" name="medium[]" id="" value="'+data.newPath1+'" /><input type="hidden" name="small[]" id="" value="'+data.newPath2+'" />';
										 li += '<a href="javascript:;" class="delImg1" style="color:red">X</a></li>';
						                $("#photo-list").prepend(li);
						            }
						        });
						    });
						 </script>
						 	<!-- 异步删除图片-->
						<script type="text/javascript">
							$(function(){
								$(".delImg1").live("click",function(){
									var url = $(this).parents("li").attr("url");
									var _this=$(this);
									$.ajax({
										type:"post",
										url:"<?php echo U('ajaxDelImg1')?>",
										data:{url:url},
										dataType:"json",
										success:function(data){
											if(data==1){
												_this.parents("li").remove();
											}
										}
									});
								})
							})
						</script>
					</td>
					<td id='photo-list'></td>
				</tr>
			</table>
			<table class='table'>
				<tr class="next_show">
					<th class="btn btn-primary">商品详细</th>
					<script id="editor" type="text/plain" style="width:100%;height:500px;" name="intro"></script>
		    		<script>
		        		var ue = UE.getEditor('editor');
		   			</script>
				</tr>
			</table>

			<table class='table'>
				<tr class="next_show">
					<th class="btn btn-primary">售后服务</th>
					<script id="ed" type="text/plain" style="width:100%;height:500px;" name="service"></script>
		    		<script>
		        		var ue = UE.getEditor('ed');
		   			</script>
				</tr>
			</table>
			<input type="submit" value="确认添加" class="btn btn-primary btn-block btn-large" />
		</fieldset>
	</form>

	</div>
	</div>
	</div>
</body>
</html>
